package com.mykt.baseResult;

import com.mykt.constant.ResultStatusConstants;
import lombok.Data;
import java.io.Serializable;

/**
 * 自定义 响应结果
 */

@Data
public class RespondsResult<T> implements Serializable {

    private Integer code; //编码：1成功，0和其它数字为失败
    private String msg; //错误信息
    private T data; //数据

    public static <T> RespondsResult<T> success() {
        RespondsResult<T> result = new RespondsResult<T>();
        result.code = ResultStatusConstants.SUCCESS_STATUS;
        result.msg=ResultStatusConstants.SUCCESS_MSG;
        return result;
    }

    /*public static <T> RespondsResult<T> success(int resultInt) {
        RespondsResult<T> result = new RespondsResult<T>();
        result.code = ResultStatusConstants.SUCCESS_STATUS;
        result.msg = ResultStatusConstants.SUCCESS_MSG;
        return result;
    }*/

    public static <T> RespondsResult<T> success(T object) {
        RespondsResult<T> result = new RespondsResult<T>();
        result.data = object;
        result.msg = ResultStatusConstants.SUCCESS_MSG;
        result.code = ResultStatusConstants.SUCCESS_STATUS;
        return result;
    }

    public static <T> RespondsResult<T> error() {
        RespondsResult result = new RespondsResult();
        result.msg = ResultStatusConstants.ERROR_MSG;
        result.code = ResultStatusConstants.ERROR_STATUS;
        return result;
    }

    public static <T> RespondsResult<T> error(String msg) {
        RespondsResult result = new RespondsResult();
        result.msg = msg;
        result.code = ResultStatusConstants.ERROR_STATUS;
        return result;
    }




}
